package com.zhongyouyun.admin.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhongyouyun.admin.mapper.MenuMapper;
import com.zhongyouyun.admin.model.MenuModel;
import com.zhongyouyun.admin.service.DictService;
import com.zhongyouyun.admin.service.MenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;

/**
 * @Author: shenyi
 * @Date: 2021-09-23
 * @Description: 资源表服务实现类
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuModel> implements MenuService {

    @Autowired
    private DictService dictService;

    /*
     * @Author: shenyi
     * @Date: 2021-09-08
     * @Description: 分页查询
     * @param page 分页数据  lambdaQueryWrapper where 条件 和排序
     */
    @Override
    public IPage<MenuModel> selectPage(Page<MenuModel> page, QueryWrapper<MenuModel> queryWrapper) {
        return this.baseMapper.selectPage(page, queryWrapper);
    }


    /*
     * @Author: shenyi
     * @Date: 2021-09-08
     * @Description: 查询全部
     * @param   lambdaQueryWrapper where 条件 和排序
     */
    @Override
    public List<MenuModel> selectList(QueryWrapper<MenuModel> queryWrapper) {
        return this.baseMapper.selectList(queryWrapper);
    }

    /*
     * @Author: shenyi
     * @Date: 2021-09-08
     * @Description: 查询全部
     * @param   lambdaQueryWrapper where 条件 和排序
     */
    @Override
    public List<MenuModel> findMenuTreeList() {
        List<MenuModel> menuModelList = this.baseMapper.findMenuTreeList();
        List<MenuModel> list = com.zhongyouyun.utils.TreeUtil.listToTree(menuModelList);
        return list;
    }

    @Override
    public List<MenuModel> findMenuALLTreeList() {
        List<MenuModel> menuModelList = this.baseMapper.findMenuTreeList();
        return menuModelList;
    }
}
